package com.atguigu.gmall.activity.controller;

import com.atguigu.gmall.activity.service.SeckillService;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月15日 11:20
 * @ClassName:SeckillController
 * @Description: TODO
 */
@RestController
@RequestMapping("/seckill/goods")
public class SeckillGoodsController {

    @Autowired
    private SeckillService seckillService;

    /**
     * 查询商品列表
     * @param time
     * @return
     */
    @GetMapping("/list/{time}")
    public Result getGoodsList(@PathVariable(value = "time") String time){
        List<SeckillGoods> seckillGoods = seckillService.getSeckillGoods(time);
        System.out.println(seckillGoods);
        return Result.ok(seckillGoods);
    }

    /**
     * 查询商品列表
     * @param time
     * @return
     */
    @GetMapping("/list/{time}/{id}")
    public Result getGoods(@PathVariable(value = "time") String time,
                           @PathVariable(value = "id") String id){
        SeckillGoods seckillGoods = seckillService.getSeckillGood(time,id);
        return Result.ok(seckillGoods);
    }


}
